import config from "@/config";
import http from "@/utils/request";

export default {
	add: {
		url: `${config.API_URL}/menu/add`,
		name: "新增菜单",
		post: async function (data) {
			return await http.post(this.url, data);
		},
	},
	update: {
		url: `${config.API_URL}/menu/update`,
		name: "编辑菜单",
		post: async function (data) {
			return await http.post(this.url, data);
		},
	},
	remove: {
		url: `${config.API_URL}/menu/remove`,
		name: "删除菜单",
		put: async function (data) {
			return await http.put(this.url + "/" + data);
		},
	},
	batchRemove: {
		url: `${config.API_URL}/menu/remove/batch`,
		name: "删除菜单",
		post: async function (data) {
			return await http.post(this.url, data);
		},
	},
	changeLevel: {
		url: `${config.API_URL}/menu/change/level`,
		name: "改变序号和层级",
		post: async function (draggingNodeId, dropNodeId, dropType) {
			return await http.post(
				this.url +
					"?draggingNodeId=" +
					draggingNodeId +
					"&dropNodeId=" +
					dropNodeId +
					"&dropType=" +
					dropType,
				null
			);
		},
	},
};
